#
# @lc app=leetcode.cn id=1417 lang=python
#
# [1417] 重新格式化字符串
#

# @lc code=start
class Solution(object):
    def reformat(self, s):
        """
        :type s: str
        :rtype: str
        """
        s=sorted(s)
        result=[]
        l=0;r=len(s)-1
        while s[l].isdigit() and s[r].isalpha():
            result.append(s[l])
            result.append(s[r])
            l+=1
            r-=1
        if l==r:
            if s[l].isdigit():
                result.append(s[l])
            else:
                result.insert(0,s[l])
        elif r>l:
            return ""
        return "".join(result)
# @lc code=end

